package ink.lovejinhu.leetcode;

public class Solution_0283 {
    /**
     * 移动零
     *
     * @param nums
     */
    public void moveZeroes(int[] nums) {
        /**
         * i指针寻找0，j记录0要存储的位置
         */
        for (int i = 0, j = nums.length - 1; i < j; ) {

            if (nums[i] == 0) {
                int temp = nums[j];
                int change = Integer.MAX_VALUE;
                for (int k = j - 1; k >= i; k--) {
                    change = nums[k];
                    nums[k] = temp;
                    temp = change;
                }
                nums[j] = 0;
                j--;
            } else {
                i++;
            }
        }
    }
}
